﻿#ifndef CFILESTORAGEIMPL_H
#define CFILESTORAGEIMPL_H

#define NOMINMAX // 关键：禁用 Windows 的 min/max 宏

#include <cstdint>
#include <string>
#include <vector>

class CFileStorageImpl
{
public:
    CFileStorageImpl();
    ~CFileStorageImpl() = default;

    void setServiceAddress(const std::string &url);
    std::string getLastErrorText() const;

    bool pushFile(const std::string &localPath, const std::string &remotePath);
    bool pullFile(const std::string &localPath, const std::string &remotePath);
    bool pushData(const std::vector<uint8_t> &localData, const std::string &remotePath);
    bool pullData(std::vector<uint8_t> &localData, const std::string &remotePath);

private:
    std::string serviceAddress;
    std::string lastErrorText;
    static const size_t CHUNK_SIZE = 10 * 1024 * 1024; // 10MB

    // 辅助函数
    bool sendChunk(const std::string &remotePath, uint64_t offset, const std::vector<uint8_t> &chunk);
    bool receiveChunk(const std::string &remotePath, uint64_t offset, std::vector<uint8_t> &chunk);
    static std::string base64Encode(const std::vector<uint8_t> &data);
    static std::vector<uint8_t> base64Decode(const std::string &encoded);
};

#endif // CFILESTORAGEIMPL_H
